package leetcode.code1780;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	public boolean checkPowersOfThree(int n) {
		int last = -1;
		while (n > 0) {
			int cur = (int) (Math.log10(n) / Math.log10(3));
			if (cur == last) {
				return false;
			}
			last = cur;
			n -= Math.pow(3, cur);
		}
		return n == 0;
	}

	@Override
	public void debug4() {
		H.compare(true, this.checkPowersOfThree(243));
		H.compare(true, this.checkPowersOfThree(6574365));
//		H.compare(true, this.checkPowersOfThree(6378022));
//		H.compare(true, this.checkPowersOfThree(12));
//		H.compare(true, this.checkPowersOfThree(91));
//		H.compare(false, this.checkPowersOfThree(21));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
